package com.cuanbo.dualscreenteachfu.utils;

import android.content.Intent;

import com.cuanbo.dualscreenteachfu.base.App;
import com.cuanbo.dualscreenteachfu.constant.CbConstant;
import com.cuanbo.dualscreenteachfu.constant.MatrixConstant;

public class BroadcastUtil {

    public static void sendBroadcastToZhuScreen(int type) {
        Intent intent = new Intent("com.cuanbo.dralscreenteachzhu.action");
        intent.putExtra("type", type);
        App.getInstance().sendBroadcast(intent);
    }

    public static void sendBroadcastToZhuScreen(int type,String data) {
        Intent intent = new Intent("com.cuanbo.dralscreenteachzhu.action");
        intent.putExtra("type", type);
        intent.putExtra("data", data);
        App.getInstance().sendBroadcast(intent);
    }

    public static void sendBroadcast(int type, String strData) {
        Intent intent = new Intent(CbConstant.ACTION);
        intent.putExtra("type", type);
        intent.putExtra("strData", strData);
        App.getInstance().sendBroadcast(intent);
    }

    /**
     * 向Action为com.cuanbo.wisroomandroid.tcp发送广播
     *
     * @param type MatrixConstant类中的TYPE开头的类型
     */
    public static void sendMatrixBroadcast(int type) {
        if (App.getInstance() == null) return;
        //LogUtil.add("类型", "" + type + " 携带数据:" + strData, "发送矩阵广播");
        Intent intent = new Intent(MatrixConstant.MATRIX_ACTION);
        intent.putExtra("type", type);
        App.getInstance().sendBroadcast(intent);
    }

    /**
     * 向Action为com.cuanbo.wisroomandroid.tcp发送广播
     *
     * @param type    MatrixConstant类中的TYPE开头的类型
     * @param strData 要传输的数据，字符串类型
     */
    public static void sendMatrixBroadcast(int type, String strData) {
        if (App.getInstance() == null) return;
        //LogUtil.add("类型", "" + type + " 携带数据:" + strData, "发送矩阵广播");
        Intent intent = new Intent(MatrixConstant.MATRIX_ACTION);
        intent.putExtra("type", type);
        intent.putExtra("strData", strData);
        App.getInstance().sendBroadcast(intent);
    }

    public static void sendMatrixBroadcast(int type, byte[] byteAry) {
        if (App.getInstance() == null) return;
        //LogUtil.add("类型", "" + type + " 携带数据:" + strData, "发送矩阵广播");
        Intent intent = new Intent(MatrixConstant.MATRIX_ACTION);
        intent.putExtra("type", type);
        intent.putExtra("byteAry", byteAry);
        App.getInstance().sendBroadcast(intent);
    }
}
